package upgrade

import (
	"encoding/json"
	"errors"
	"fmt"
	"kop/modules/configuration/client"
	"kop/util/log"
)

func init() {

	var b = client.Load("UpgradeTemplate")
	if err := json.Unmarshal(b, &UpgradeConfigs); err != nil {
		panic(err)
	}

	log.Info("Load UpgradeTemplate.json success.")

}

type (
	UpgradeConfig struct {
		ID       int32 // 培养ID
		Type     int32 // 培养类型
		Mode     int32 // 培养方式
		Quality  int32 // 培养品质
		GradeMax int32 // 最大等级
		//Value1          int32   // 值1
		//Value2          int32   // 值2
		//Value3          int32   // 值3
		//Value4          int32   // 值4
		//Value5          int32   // 值5
		CostType int32 // 属性类型
		//MoneyType     int32 // 货币类型
		//MoneyCount    int64 // 消耗数量
		ItemID        int32 // 物品ID
		ItemCount     int32 // 消耗数量
		AttributeType int32 // 属性类型
		AttributeID   int32 // 属性ID
		AttributeRate int32 // 属性比例
		//ConfigID      int32 // 配置ID
		//ConnectID     int32 // 关联ID
	}
)

var (
	UpgradeConfigs = map[int32]UpgradeConfig{}
)

func GetByUpgradeID(ID int32) (UpgradeConfig, error) {

	var conf, ok = UpgradeConfigs[ID]
	if ok {
		return conf, nil
	}

	return UpgradeConfig{}, errors.New(fmt.Sprintf("UpgradeID not found [%d]", ID))
}
